package com.linden.std.exception;

import com.linden.std.enums.ExceptionEnums;

/**
 * 自定义异常类
 * 用于处理业务逻辑中的异常情况
 */
public class CustomException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    // 异常码
    private Integer code;

    // 异常信息
    private String message;

    public CustomException() {
        super();
    }

    public CustomException(String message) {
        super(message);
        this.message = message;
    }

    public CustomException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public CustomException(String message, Throwable cause) {
        super(message, cause);
        this.message = message;
    }

    public CustomException(Integer code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.message = message;
    }

    public CustomException(ExceptionEnums exceptionEnums) {
        super(exceptionEnums.getMessage());
        this.code = exceptionEnums.getCode();
        this.message = exceptionEnums.getMessage();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}

